package com.damacheng009.future.alarm.toolkit;

import org.nutz.dao.Dao;
import org.nutz.dao.TableName;

import com.damacheng009.future.alarm.domain.TAlarm;
import com.damacheng009.future.alarm.domain.TKLine;

import cn.hutool.core.util.ArrayUtil;

public class DaoTool {
		
	public static void init() {
		Dao dao = createDao(null);
		
		dao.create(TAlarm.class, false);
		
		//Daos.createTablesInPackage(dao, TAlarm.class, true);
		//Daos.migration(dao, TAlarm.class, true, false, true);
		
		for (String code : ArrayUtil.addAll(GlobalConfig.sinaCodeList, GlobalConfig.stockCodeList)) {
			TableName.set(code);
			dao.create(TKLine.class, false);
			// Daos.createTablesInPackage(dao, TKLine.class, false);
			// Daos.createTablesInPackage(dao, "com.damacheng009.future.alarm.domain", false);
	        // Daos.migration(dao, TKLine.class, true, false, true);
			// Daos.migration(dao, "com.damacheng009.future.alarm.domain", true, false, true);
		}
	}

	public static Dao createDao(String code) {
		Dao dao = (Dao) SpringBootBeanTool.getBean("dao");
		if (code != null) {
			TableName.set(code);
		}
		
		return dao;
	}

}